package cn.panda.edu.service.impl;

import cn.panda.edu.dao.EnrollStudentsMapper;
import cn.panda.edu.model.EnrollStudents;
import cn.panda.edu.service.EnrollStudentsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class EnrollStudentsServiceImpl implements EnrollStudentsService {
	
	@Autowired
	private EnrollStudentsMapper enrollStudentsMapper;
	
	@Override
	public int deleteByPrimaryKey(Integer enrollId) {
		// TODO Auto-generated method stub
		return enrollStudentsMapper.deleteByPrimaryKey(enrollId);
	}

	@Override
	public int insert(EnrollStudents record) {
		// TODO Auto-generated method stub
		return enrollStudentsMapper.insert(record);
	}

	@Override
	public int insertSelective(EnrollStudents record) {
		// TODO Auto-generated method stub
		return enrollStudentsMapper.insertSelective(record);
	}

	@Override
	public EnrollStudents selectByPrimaryKey(Integer enrollId) {
		// TODO Auto-generated method stub
		return enrollStudentsMapper.selectByPrimaryKey(enrollId);
	}

	@Override
	public int updateByPrimaryKeySelective(EnrollStudents record) {
		// TODO Auto-generated method stub
		return enrollStudentsMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(EnrollStudents record) {
		// TODO Auto-generated method stub
		return enrollStudentsMapper.updateByPrimaryKey(record);
	}

	@Override
	public PageInfo<EnrollStudents> selectByPageAndSelective(String majorName, int pageIndex, int pageSize) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<>();
		map.put("majorName", majorName);
		PageHelper.startPage(pageIndex, pageSize);
		List<EnrollStudents> eList = enrollStudentsMapper.selectByName(map);
		PageInfo<EnrollStudents> ePageInfo = new PageInfo<>(eList);
		return ePageInfo;
	}

}
